package com.ghyf.mplay.util;

import android.graphics.Typeface;

import com.ghyf.mplay.value.ConstantValue;

/**
 * 由本地的ttf文件创建字体
 * 
 * @author 陈小红
 * 
 */
public class TypeFaceFactory {
	public static final String TAG="TypeFaceFactory";

	private TypeFaceFactory() {
		super();
	}

	static Typeface fzgl = null;
	static Typeface fzxz = null;
	static Typeface hksn = null;
	static Typeface hwxk = null;
	static Typeface hwxs = null;
	static Typeface ls = null;
	static Typeface ml = null;
	static Typeface yy = null;
	static Typeface wryh = null;
	static Typeface pglh = null;
	static Typeface mzd = null;
	static Typeface arial = null;
	static Typeface simyou = null;

	// 生成对应的字体
	static {
		//TODO 字体文件的路径未定，最好放emmc flash
		fzgl = Typeface.createFromFile(ConstantValue.ROOT_DIR
				+ "fonts/fzgl.ttf");	//古隶
		fzxz = Typeface.createFromFile(ConstantValue.ROOT_DIR
				+ "fonts/fzxz.ttf");	//小篆
		hwxk = Typeface.createFromFile(ConstantValue.ROOT_DIR
				+ "fonts/hwxk.ttf");	//楷体
		wryh = Typeface.createFromFile(ConstantValue.ROOT_DIR
				+ "fonts/wryh.ttf");	//黑体
		hwxs = Typeface.createFromFile(ConstantValue.ROOT_DIR
				+ "fonts/hwxs.ttf");	//宋体
		mzd =  Typeface.createFromFile(ConstantValue.ROOT_DIR 
				+ "fonts/mzd.ttf"); //毛体
		arial= Typeface.createFromFile(ConstantValue.ROOT_DIR 
				+ "fonts/arial.ttf"); //Arial
		simyou= Typeface.createFromFile(ConstantValue.ROOT_DIR 
				+ "fonts/simyou.ttf"); //幼圆
	}

	/**
	 * 根据字体名称返回对应的字体
	 * @param fontName 字体名称
	 * @return 字体
	 */
	public static Typeface createTypeface(String fontName) {
		if ("古隶".equals(fontName)) {
			return fzgl;
		} else if ("小篆".equals(fontName)) {
			return fzxz;
		} else if ("楷体".equals(fontName)) {
			return hwxk;
		} else if ("黑体".equals(fontName)) {
			return wryh;
		} else if ("宋体".equals(fontName)) {
			return hwxs;
		}else if ("毛体".equals(fontName)) {
			return mzd;
		}else if ("Arial".equals(fontName)) {
			return arial;
		}else if ("幼圆".equals(fontName)) {
			return simyou;
		}
		return hwxs;
	}

}
